package com.Endurancer.manager.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.Endurancer.common.annotation.Log;
import com.Endurancer.common.core.controller.BaseController;
import com.Endurancer.common.core.domain.AjaxResult;
import com.Endurancer.common.enums.BusinessType;
import com.Endurancer.manager.domain.SiteSchedule;
import com.Endurancer.manager.service.ISiteScheduleService;
import com.Endurancer.common.utils.poi.ExcelUtil;
import com.Endurancer.common.core.page.TableDataInfo;

/**
 * 建站日程Controller
 *
 * @author Endurancer
 * @date 2025-02-02
 */
@RestController
@RequestMapping("/manager/schedule")
public class SiteScheduleController extends BaseController
{
    @Autowired
    private ISiteScheduleService siteScheduleService;

    /**
     * 查询建站日程列表
     */
//    @PreAuthorize("@ss.hasPermi('manager:schedule:list')")
    @GetMapping("/list")
    public TableDataInfo list(SiteSchedule siteSchedule)
    {
        startPage();
        List<SiteSchedule> list = siteScheduleService.selectSiteScheduleList(siteSchedule);
        return getDataTable(list);
    }

    /**
     * 导出建站日程列表
     */
    @PreAuthorize("@ss.hasPermi('manager:schedule:export')")
    @Log(title = "建站日程", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SiteSchedule siteSchedule)
    {
        List<SiteSchedule> list = siteScheduleService.selectSiteScheduleList(siteSchedule);
        ExcelUtil<SiteSchedule> util = new ExcelUtil<SiteSchedule>(SiteSchedule.class);
        util.exportExcel(response, list, "建站日程数据");
    }

    /**
     * 获取建站日程详细信息
     */
    @PreAuthorize("@ss.hasPermi('manager:schedule:query')")
    @GetMapping(value = "/{scheduleId}")
    public AjaxResult getInfo(@PathVariable("scheduleId") Long scheduleId)
    {
        return success(siteScheduleService.selectSiteScheduleByScheduleId(scheduleId));
    }

    /**
     * 新增建站日程
     */
    @PreAuthorize("@ss.hasPermi('manager:schedule:add')")
    @Log(title = "建站日程", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SiteSchedule siteSchedule)
    {
        return toAjax(siteScheduleService.insertSiteSchedule(siteSchedule));
    }

    /**
     * 修改建站日程
     */
    @PreAuthorize("@ss.hasPermi('manager:schedule:edit')")
    @Log(title = "建站日程", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SiteSchedule siteSchedule)
    {
        return toAjax(siteScheduleService.updateSiteSchedule(siteSchedule));
    }

    /**
     * 删除建站日程
     */
    @PreAuthorize("@ss.hasPermi('manager:schedule:remove')")
    @Log(title = "建站日程", businessType = BusinessType.DELETE)
	@DeleteMapping("/{scheduleIds}")
    public AjaxResult remove(@PathVariable Long[] scheduleIds)
    {
        return toAjax(siteScheduleService.deleteSiteScheduleByScheduleIds(scheduleIds));
    }
}
